Overview
Theserver package provides the SSH server that handles client connections and manages Bubble Tea sessions for the Duet TUI.
Types
Server
Main server struct that manages SSH connections and room state.Functions
New
Creates a new Duet server instance.string
required
The address to listen on (e.g., “localhost:2222”)
string
required
Path to the SSH host key file
string
Optional URL for the AI worker service. If empty, AI features will be disabled
*Server instance
Example:
Start
Starts the SSH server and blocks until shutdown.- Starts SSH server with Bubble Tea middleware
- Listens for OS interrupt signals (SIGINT, SIGTERM)
- Performs graceful shutdown with 10-second timeout
- Logs server lifecycle events
Implementation Details
SSH Middleware
The server uses Wish middleware for SSH handling:- Bubble Tea Middleware: Manages TUI sessions
- Logging Middleware: Logs connection events
Session Handling
Each SSH connection:- Extracts username (defaults to “guest”)
- Creates a Bubble Tea renderer
- Detects terminal type (special handling for xterm-ghostty)
- Initializes a UI model with the room manager
- Launches in alternate screen mode